home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / tools / lu62 / checkend.c < prev    next >
C/C++ Source or Header  |  1996-07-10  |  14KB  |  413 lines

  1.  /********************************************************
  2.  *                                                       *
  3.  *                   CHECK_END                           *
  4.  *                                                       *
  5.  *  Function : Checks if the processing of a verb is     *
  6.  *             complete. If not, then place the RCB in   *
  7.  *             the waiting queue.                        *
  8.  *  Input  :  Pointer to the "common" struct. The first  *
  9.  *            12 bytes of it contains the "repass"       *
  10.  *            structure.                                 *
  11.  *  Output :  If the verb processing is complete, then   *
  12.  *            the RCB will be removed from wait queue;   *
  13.  *            otherwise the RCB will be placed in the    *
  14.  *            wait queue.                                *
  15.  *                                                       *
  16.  * CopyRight 1995. Nicholas Poljakov all rights reserved.*
  17.  *                                                       *
  18.  ********************************************************/
  19. #include <alloc.h>
  20. #include <attlu.h>
  21. #include <common.h>
  22. #include <conf.h>
  23. #include <confd.h>
  24. #include <dall.h>
  25. #include <detach.h>
  26. #include <flush.h>
  27. #include <gatt.h>
  28. #include <partner.h>
  29. #include <post.h>
  30. #include <preptrcv.h>
  31. #include <rcb.h>
  32. #include <recimmed.h>
  33. #include <recwait.h>
  34. #include <repass.h>
  35. #include <rtsend.h>
  36. #include <sendat.h>
  37. #include <sender.h>
  38. #include <state1.h>
  39. #include <tcb.h>
  40. #include <test.h>
  41. #include <tps.h>
  42. #include <string.h>
  43.  
  44. int asfd;    /* FiFo descriptor for AS */
  45. extern int sw_retry[10];
  46. #if OS_TYPE == 0
  47. extern int ss_ptr;
  48. #endif
  49. int add_wait();
  50. int del_wait();
  51. int write();
  52. int sk_r_wt(void *);
  53. int SendBlock(void *, void *);
  54. int setrc(void *, void *);
  55. int sendhsf(void *);
  56. int sendhs(void *);
  57. int sendbm(void *, void *);
  58. int sendat(void *);
  59. int rtsend(void *);
  60. unsigned long rmfmh5(void *, void *);
  61. int recwait(void *);
  62. int rcvru(void *, void *);
  63. int rcvhs(void *, void *, void *, void *);
  64. int ralloc(void *, void *);
  65. int psrm(int, void *, void *);
  66. int ps_conv(int, void *);
  67. int proterr(void *, unsigned long);
  68. int preptrcv(void *, void *);
  69. int post_rcb(void *);
  70. struct repass *postopen(void *);
  71. int phsrec(void *);
  72. int pfmh5(void *);
  73. int opndst(void *);
  74. int obtsess(void *, unsigned char);
  75. int Lrf_handler(void *);
  76. int get_sess(void *, void *);
  77. int get_attr(void *);
  78. int fsm_error(unsigned char, void *);
  79. int fsm_conv(unsigned char, unsigned char, void *);
  80. int flush (void *);
  81. int dcp(void *);
  82. int dealloc(void *);
  83. int crtp(void *);
  84. int conv(void *);
  85. int chkparm(void *, void *);
  86. struct rqb *call_appl(void *);
  87. int buffmng(unsigned char, void *, void *, void *, unsigned, unsigned char, unsigned);
  88. unsigned long attltck(void *);
  89. unsigned long attacheck(void *);
  90. char *cgetmem(int, int);
  91. int sendhsf(void *);
  92. int opndst(void *);
  93. int alloc_rcb(void *, void *);
  94. int allocate(void *);
  95. int clsdst(void *);
  96. int add_wait(struct rcb *);
  97. int waitst(void);
  98. int del_wait(struct rcb *);
  99.  
  100. check_end(code, p_rep)
  101. unsigned int code;
  102. struct repass *p_rep;
  103. {
  104.     struct rcb *p_rcb;
  105.  
  106. #if OS_TYPE == 1
  107. /*********  Trace facility **********/
  108. unsigned int rtype;   /* type of record */
  109. unsigned int pnum;    /* point number */
  110. char pname[8];        /* name of module */
  111. char *drec;           /* record for dump */
  112. int  lenr;            /* record length */
  113.  
  114. rtype = INPROC;
  115. strcpy(pname, "checked");
  116. pnum = 1;
  117. drec = p_rep;
  118. lenr = 200;
  119. gtf(rtype, pname, pnum, drec, lenr);
  120. /***********************************/
  121.  
  122. printf("LUPS...checkend...code = %x, p_rep = %x\n", code, p_rep);
  123. #endif
  124.  
  125.     if (code == 0xffff) { /* error in getverb subr. */
  126.         return (0);
  127.     }
  128.     if ((code == -1)||
  129.         (code == FMHRCV)||(code == SESSINI)||
  130. #if OS_TYPE == 0 /* MS-DOS */
  131.         (code == DR) || (code == POSTOPEN) ||
  132. #endif
  133.         (code == CLSSESS)||(code == CLSSESS)) {
  134. #if OS_TYPE == 1  /* Unix V */
  135.         free(p_rep);
  136. #endif
  137.         return (0); /* Invalid POST or no need to response*/
  138.     }
  139.     if (p_rep -> complete == 0) {
  140. #if OS_TYPE == 1
  141.         FifoWrt(p_rep); /* Write response to Trans. Prog. FIFO */
  142.         free(p_rep);
  143. #endif
  144.     }
  145.     else {
  146.             p_rcb = p_rep -> p_rcb;
  147.             add_wait(p_rcb);
  148. #if OS_TYPE == 0
  149.             waitst();  /* wait events from low levels */
  150.             del_wait(p_rcb);
  151.             if (code != Allocate) {
  152.                 sw_retry[ss_ptr - 1] = YES;
  153.             }
  154. #endif
  155.          }
  156.     return (0);
  157. }
  158. #if OS_TYPE == 1  /* Unix - V */
  159. FifoWrt(ptr)
  160. struct com *ptr;
  161. {
  162.     struct repass *p_rep;
  163.     struct rcb *p_rcb;
  164.     struct tcb *p_tcb;
  165.     struct rcwait *p_rw;
  166.     struct recimmed *p_ri;
  167.     int short tp_fd;
  168.     int i;
  169.     int rest;
  170. #if DEBUG == 1
  171. printf("LUPS...FifoWrt...code = %x, asfd = %d\n", ptr -> code, asfd);
  172. #endif
  173.     p_rep = ptr;
  174.     switch (ptr -> code) {
  175.         case Attach_lu:
  176.                        {
  177.                          i = write(asfd, ptr, sizeof(struct attach_lu));
  178. printf("LUPS...checkend...after write i = %d, asfd = %d\n", i, asfd);
  179.                          break;
  180.                        }
  181.         case Detach_lu:
  182.                        {
  183. #if DEBUG == 0
  184.                          write(asfd, ptr, sizeof(struct detach));
  185. #endif
  186.                          break;
  187.                        }
  188.         case TP_STARTED:
  189.                        {
  190. #if DEBUG == 0
  191.                          i = write(asfd, ptr, sizeof(struct tp_started));
  192. printf("LUPS...checkend...after write i = %d, asfd = %d\n", i, asfd);
  193. #endif
  194.                          break;
  195.                        }
  196.         case Allocate:
  197.                        {
  198.                          p_rcb = p_rep -> p_rcb;
  199.                          p_tcb = p_rcb -> p_tcb;
  200.                          tp_fd = p_rep -> tp_fd;
  201.                          if (tp_fd == 0) {
  202.                             break; /* TP can't be identificated */
  203.                          }
  204. #if DEBUG == 0
  205.                          i = write(tp_fd, ptr, sizeof(struct allocate));
  206. printf("LUPS...checkend...after write i = %d, asfd = %d\n", i, asfd);
  207. #endif
  208.                          break;
  209.                        }
  210.         case Confirm:
  211.                        {
  212.                          p_rcb = p_rep -> p_rcb;
  213.                          p_tcb = p_rcb -> p_tcb;
  214.                          tp_fd = p_rep -> tp_fd;
  215.                          if (tp_fd == 0) {
  216.                             break; /* TP can't be identificated */
  217.                          }
  218.                          write(tp_fd, ptr, sizeof(struct confirm));
  219.                          break;
  220.                        }
  221.         case COnfirmed:
  222.                        {
  223.                          p_rcb = p_rep -> p_rcb;
  224.                          p_tcb = p_rcb -> p_tcb;
  225.                          tp_fd = p_rep -> tp_fd;
  226.                          if (tp_fd == 0) {
  227.                             break; /* TP can't be identificated */
  228.                          }
  229.                          write(tp_fd, ptr, sizeof(struct confirmed));
  230.                          break;
  231.                        }
  232.         case Deallocate:
  233.                        {
  234.                          tp_fd = p_rep -> tp_fd;
  235.                          if (tp_fd == 0) {
  236.                             break; /* TP can't be identificated */
  237.                          }
  238. #if DEBUG == 0
  239.                          write(tp_fd, ptr, sizeof(struct deallocate));
  240. #endif
  241.                          break;
  242.                        }
  243.         case Flush:
  244.                        {
  245.                          p_rcb = p_rep -> p_rcb;
  246.                          p_tcb = p_rcb -> p_tcb;
  247.                          tp_fd = p_rep -> tp_fd;
  248.                          if (tp_fd == 0) {
  249.                             break; /* TP can't be identificated */
  250.                          }
  251. #if DEBUG == 0
  252.                          write(tp_fd, ptr, sizeof(struct flush));
  253. #endif
  254.                          break;
  255.                        }
  256.         case Get_attributes:
  257.                        {
  258.                          p_rcb = p_rep -> p_rcb;
  259.                          p_tcb = p_rcb -> p_tcb;
  260.                          tp_fd = p_rep -> tp_fd;
  261.                          if (tp_fd == 0) {
  262.                             break; /* TP can't be identificated */
  263.                          }
  264.                          write(tp_fd, ptr, sizeof(struct get_attributes));
  265.                          break;
  266.                        }
  267.         case Post_on_receipt:
  268.                        {
  269.                          p_rcb = p_rep -> p_rcb;
  270.                          p_tcb = p_rcb -> p_tcb;
  271.                          tp_fd = p_rep -> tp_fd;
  272.                          if (tp_fd == 0) {
  273.                             break; /* TP can't be identificated */
  274.                          }
  275.                          write(tp_fd, ptr, sizeof(struct post_rcpt));
  276.                          break;
  277.                        }
  278.         case Prepare_to_receive:
  279.                        {
  280.                          p_rcb = p_rep -> p_rcb;
  281.                          p_tcb = p_rcb -> p_tcb;
  282.                          tp_fd = p_rep -> tp_fd;
  283.                          if (tp_fd == 0) {
  284.                             break; /* TP can't be identificated */
  285.                          }
  286. #if DEBUG == 0
  287.                          write(tp_fd, ptr, sizeof(struct p_rcv));
  288. #endif
  289.                          break;
  290.                        }
  291.         case Receive_and_wait:
  292.                        {
  293.                          p_rw = ptr;
  294.                          p_rcb = p_rep -> p_rcb;
  295.                          p_tcb = p_rcb -> p_tcb;
  296.                          tp_fd = p_rep -> tp_fd;
  297.                          if (tp_fd == 0) {
  298.                             break; /* TP can't be identificated */
  299.                          }
  300. #if DEBUG == 0
  301.                          write(tp_fd, ptr, sizeof(struct rcwait));
  302.                          if ((i = p_rw -> data_lt) != 0) {
  303.                             do {
  304.                                 if (i <= MAX_SEG) {
  305.                                     rest = i;
  306.                                     i = 0;
  307.                                 }
  308.                                 else
  309.                                         {
  310.                                             rest = MAX_SEG;
  311.                                             i -= MAX_SEG;
  312.                                         }
  313.                                 write(tp_fd, p_rw -> data_addr, rest);
  314.                             } while (i != 0);
  315.                             free(p_rw -> data_addr);
  316.                          }
  317. #endif
  318.                          break;
  319.                        }
  320.         case Receive_immediate:
  321.                        {
  322.                          p_rcb = p_rep -> p_rcb;
  323.                          p_tcb = p_rcb -> p_tcb;
  324.                          tp_fd = p_rep -> tp_fd;
  325.                          if (tp_fd == 0) {
  326.                             break; /* TP can't be identificated */
  327.                          }
  328. #if DEBUG == 0
  329.                          write(tp_fd, ptr, sizeof(struct recimmed));
  330.                          if ((i = p_ri -> data_lt) != 0) {
  331.                             do {
  332.                                 if (i <= MAX_SEG) {
  333.                                     rest = i;
  334.                                     i = 0;
  335.                                 }
  336.                                 else
  337.                                         {
  338.                                             rest = MAX_SEG;
  339.                                             i -= MAX_SEG;
  340.                                         }
  341.                                 write(tp_fd, p_ri -> data_addr, rest);
  342.                             } while (i != 0);
  343.                             free(p_ri -> data_addr);
  344.                          }
  345. #endif
  346.                          break;
  347.                        }
  348.         case Request_to_send:
  349.                        {
  350.                          p_rcb = p_rep -> p_rcb;
  351.                          p_tcb = p_rcb -> p_tcb;
  352.                          tp_fd = p_rep -> tp_fd;
  353.                          if (tp_fd == 0) {
  354.                             break; /* TP can't be identificated */
  355.                          }
  356. #if DEBUG == 0
  357.                          write(tp_fd, ptr, sizeof(struct rtsend));
  358. #endif
  359.                          break;
  360.                        }
  361.         case Send_data:
  362.                        {
  363.                          p_rcb = p_rep -> p_rcb;
  364.                          p_tcb = p_rcb -> p_tcb;
  365.                          tp_fd = p_rep -> tp_fd;
  366.                          if (tp_fd == 0) {
  367.                             break; /* TP can't be identificated */
  368.                          }
  369. #if DEBUG == 0
  370.                          write(tp_fd, ptr, sizeof(struct send_data));
  371. #endif
  372.                          break;
  373.                        }
  374.         case Send_error:
  375.                        {
  376.                          p_rcb = p_rep -> p_rcb;
  377.                          p_tcb = p_rcb -> p_tcb;
  378.                          tp_fd = p_rep -> tp_fd;
  379.                          if (tp_fd == 0) {
  380.                             break; /* TP can't be identificated */
  381.                          }
  382.                          write(tp_fd, ptr, sizeof(struct send_error));
  383.                          break;
  384.                        }
  385.         case Test:
  386.                        {
  387.                          p_rcb = p_rep -> p_rcb;
  388.                          p_tcb = p_rcb -> p_tcb;
  389.                          tp_fd = p_rep -> tp_fd;
  390.                          if (tp_fd == 0) {
  391.                             break; /* TP can't be identificated */
  392.                          }
  393.                          write(tp_fd, ptr, sizeof(struct test));
  394.                          break;
  395.                        }
  396.         case FMHRCV:
  397.         case SESSINI:
  398.         case CLSSESP:
  399.         case CLSSESS:
  400.         case DR:
  401.         case POSTOPEN:
  402.                        break;
  403.  
  404.         default:
  405.                    {
  406. printf("LUPS...unexpected code...\n");
  407.                           break;
  408.                    }
  409.      }
  410.     return(0);
  411. }
  412. #endif
  413.